package health.lm.com.shop.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vondear.rxtool.RxTimeTool;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.shop.R;
import health.lm.com.shop.entity.HLPrivateMessageEntity;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.shop.adapter
 * Date：2019/8/8 17:06
 * Introduce：私信
 */
public class HLPrivateMessageAdapter extends BaseQuickAdapter<HLPrivateMessageEntity, BaseViewHolder> {
    public HLPrivateMessageAdapter(@Nullable List<HLPrivateMessageEntity> data) {
        super(R.layout.hl_activity_people_item, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, HLPrivateMessageEntity item) {
        //String time = RxTimeTool.date2String(new Date(Long.parseLong(item.getTime())), new SimpleDateFormat("yyy-MM-dd"));
        ImageLoaderHelper.getInstance().load(mContext, item.getAvatar(), helper.getView(R.id.imageView3));
        helper.setText(R.id.textView4, item.getName())
                //.setText(R.id.textView6, "关注时间：" + item.getTime())
                .setText(R.id.textView6, item.getMsg())
                .setText(R.id.textView7,item.getNum())
                .setText(R.id.textView8,item.getTime())
                .setText(R.id.textView9,item.getDepartment())
                .setGone(R.id.imageView4, false)
                .setGone(R.id.textView7, !TextUtils.isEmpty(item.getNum()) && !"0".equals(item.getNum()))
                .setGone(R.id.textView8, true)
                .setGone(R.id.textView5, false)
        ;
    }
}
